home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / mac / DirectX SDK / DXSDK / samples / Multimedia / DirectMusic / PlayAudio / PlayAudio.cpp < prev    next >
C/C++ Source or Header  |  2001-10-31  |  20KB  |  550 lines

  1. //-----------------------------------------------------------------------------
  2. // File: PlayAudio.cpp
  3. //
  4. // Desc: Plays a primary segment using DirectMusic
  5. //
  6. // Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #define STRICT
  9. #include <windows.h>
  10. #include <basetsd.h>
  11. #include <commdlg.h>
  12. #include <commctrl.h>
  13. #include <dmusicc.h>
  14. #include <dmusici.h>
  15. #include <dxerr8.h>
  16. #include <tchar.h>
  17. #include "resource.h"
  18. #include "DMUtil.h"
  19. #include "DXUtil.h"
  20.  
  21.  
  22.  
  23.  
  24. //-----------------------------------------------------------------------------
  25. // Function-prototypes
  26. //-----------------------------------------------------------------------------
  27. INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
  28. HRESULT OnInitDialog( HWND hDlg );
  29. HRESULT ProcessDirectMusicMessages( HWND hDlg );
  30. VOID    OnOpenSoundFile( HWND hDlg );
  31. HRESULT LoadSegmentFile( HWND hDlg, TCHAR* strFileName );
  32. HRESULT OnPlayAudio( HWND hDlg );
  33. VOID    EnablePlayUI( HWND hDlg, BOOL bEnable );
  34.  
  35.  
  36.  
  37.  
  38. //-----------------------------------------------------------------------------
  39. // Defines, constants, and global variables
  40. //-----------------------------------------------------------------------------
  41. #define MUSIC_VOLUME_RANGE      ( 0-(DMUS_VOLUME_MIN/4) )
  42.  
  43. CMusicManager*     g_pMusicManager          = NULL;
  44. CMusicSegment*     g_pMusicSegment          = NULL;
  45. HINSTANCE          g_hInst                  = NULL;
  46. HANDLE             g_hDMusicMessageEvent    = NULL;
  47.  
  48.  
  49.  
  50.  
  51. //-----------------------------------------------------------------------------
  52. // Name: WinMain()
  53. // Desc: Entry point for the application.  Since we use a simple dialog for 
  54. //       user interaction we don't need to pump messages.
  55. //-----------------------------------------------------------------------------
  56. INT APIENTRY WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, 
  57.                       INT nCmdShow )
  58. {
  59.     HWND    hDlg = NULL;
  60.     BOOL    bDone = FALSE;
  61.     int     nExitCode;
  62.     HRESULT hr; 
  63.     DWORD   dwResult;
  64.     MSG     msg;
  65.  
  66.     g_hInst = hInst;
  67.  
  68.     InitCommonControls();
  69.  
  70.     // Display the main dialog box.
  71.     hDlg = CreateDialog( hInst, MAKEINTRESOURCE(IDD_MAIN), 
  72.                          NULL, MainDlgProc );
  73.  
  74.     while( !bDone ) 
  75.     { 
  76.         dwResult = MsgWaitForMultipleObjects( 1, &g_hDMusicMessageEvent, 
  77.                                               FALSE, INFINITE, QS_ALLEVENTS );
  78.         switch( dwResult )
  79.         {
  80.             case WAIT_OBJECT_0 + 0:
  81.                 // g_hDPMessageEvent is signaled, so there are
  82.                 // DirectPlay messages available
  83.                 if( FAILED( hr = ProcessDirectMusicMessages( hDlg ) ) ) 
  84.                 {
  85.                     DXTRACE_ERR( TEXT("ProcessDirectMusicMessages"), hr );
  86.                     return FALSE;
  87.                 }
  88.                 break;
  89.  
  90.             case WAIT_OBJECT_0 + 1:
  91.                 // Windows messages are available
  92.                 while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) 
  93.                 { 
  94.                     if( !IsDialogMessage( hDlg, &msg ) )  
  95.                     {
  96.                         TranslateMessage( &msg ); 
  97.                         DispatchMessage( &msg ); 
  98.                     }
  99.  
  100.                     if( msg.message == WM_QUIT )
  101.                     {
  102.                         nExitCode = (int)msg.wParam;
  103.                         bDone     = TRUE;
  104.                         DestroyWindow( hDlg );
  105.                     }
  106.                 }
  107.                 break;
  108.         }
  109.     }
  110.  
  111.     return nExitCode;
  112. }
  113.  
  114.  
  115.  
  116.  
  117. //-----------------------------------------------------------------------------
  118. // Name: MainDlgProc()
  119. // Desc: Handles dialog messages
  120. //-----------------------------------------------------------------------------
  121. INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
  122. {
  123.     HRESULT hr;
  124.  
  125.     switch( msg ) 
  126.     {
  127.         case WM_INITDIALOG:
  128.             if( FAILED( hr = OnInitDialog( hDlg ) ) )
  129.             {
  130.                 DXTRACE_ERR( TEXT("OnInitDialog"), hr );
  131.                 MessageBox( hDlg, "Error initializing DirectMusic.  Sample will now exit.", 
  132.                                   "DirectMusic Sample", MB_OK | MB_ICONERROR );
  133.                 EndDialog( hDlg, 0 );
  134.                 return TRUE;
  135.             }
  136.             break;
  137.  
  138.         case WM_COMMAND:
  139.             switch( LOWORD(wParam) )
  140.             {
  141.                 case IDC_SOUNDFILE:
  142.                     OnOpenSoundFile( hDlg );
  143.                     break;
  144.  
  145.                 case IDCANCEL:
  146.                     PostQuitMessage( IDCANCEL );
  147.                     break;
  148.  
  149.                 case IDC_PLAY:
  150.                     if( FAILED( hr = OnPlayAudio( hDlg ) ) )
  151.                     {
  152.                         DXTRACE_ERR( TEXT("OnPlayAudio"), hr );
  153.                         MessageBox( hDlg, "Error playing DirectMusic segment. "
  154.                                     "Sample will now exit.", "DirectMusic Sample", 
  155.                                     MB_OK | MB_ICONERROR );
  156.                         PostQuitMessage( IDABORT );
  157.                     }
  158.                     break;
  159.  
  160.                 case IDC_STOP:
  161.                     g_pMusicSegment->Stop( DMUS_SEGF_BEAT ); 
  162.                     EnablePlayUI( hDlg, TRUE );
  163.                     break;
  164.  
  165.                 default:
  166.                     return FALSE; // Didn't handle message
  167.             }
  168.             break;
  169.  
  170.         case WM_NOTIFY:
  171.             if( wParam == IDC_TEMPO_SLIDER )
  172.             {
  173.                 static int s_nLastTempo = -1;
  174.                 int nTempo = (int)SendDlgItemMessage( hDlg, IDC_TEMPO_SLIDER, TBM_GETPOS, 0, 0 );
  175.  
  176.                 if( nTempo != s_nLastTempo )
  177.                 {
  178.                     IDirectMusicPerformance* pPerf = NULL;                
  179.                     if( g_pMusicManager )
  180.                        pPerf = g_pMusicManager->GetPerformance();
  181.                     if( NULL == pPerf )
  182.                         break;
  183.  
  184.                     s_nLastTempo = nTempo;
  185.  
  186.                     // Adjust the slider position to go between 1/4th and 4x tempo 
  187.                     FLOAT fTempo;
  188.                     if( nTempo > 4 )
  189.                         fTempo = (float)(nTempo-3);
  190.                     else
  191.                         fTempo = nTempo/4.0f;
  192.                     pPerf->SetGlobalParam( GUID_PerfMasterTempo, 
  193.                                            (void*)&fTempo, sizeof(float) );                    
  194.                 }
  195.             }
  196.             else if( wParam == IDC_VOLUME_SLIDER )
  197.             {
  198.                 static long s_nLastVolume = -1;
  199.                 long nSlider = (long)SendDlgItemMessage( hDlg, IDC_VOLUME_SLIDER, TBM_GETPOS, 0, 0 );
  200.  
  201.                 long nVolume = nSlider - MUSIC_VOLUME_RANGE;
  202.  
  203.                 if( nVolume != s_nLastVolume )
  204.                 {
  205.                     IDirectMusicPerformance* pPerf = NULL;               
  206.                     if( g_pMusicManager )
  207.                        pPerf = g_pMusicManager->GetPerformance();
  208.                     if( NULL == pPerf )
  209.                         break;
  210.  
  211.                     s_nLastVolume = nVolume;
  212.  
  213.                     // Adjust the slider position to match GUID_PerfMasterTempo range
  214.                     pPerf->SetGlobalParam( GUID_PerfMasterVolume, 
  215.                                            (void*)&nVolume, sizeof(long) );                    
  216.                 }
  217.             }
  218.  
  219.             break;
  220.  
  221.         case WM_DESTROY:
  222.             // Cleanup everything
  223.             SAFE_DELETE( g_pMusicSegment );
  224.             SAFE_DELETE( g_pMusicManager );
  225.             CloseHandle( g_hDMusicMessageEvent );
  226.             break; 
  227.  
  228.         default:
  229.             return FALSE; // Didn't handle message
  230.     }
  231.  
  232.     return TRUE; // Handled message
  233. }
  234.  
  235.  
  236.  
  237.  
  238. //-----------------------------------------------------------------------------
  239. // Name: OnInitDialog()
  240. // Desc: Initializes the dialogs (sets up UI controls, etc.)
  241. //-----------------------------------------------------------------------------
  242. HRESULT OnInitDialog( HWND hDlg )
  243. {
  244.     HRESULT hr; 
  245.  
  246.     // Load the icon
  247.     HICON hIcon = LoadIcon( g_hInst, MAKEINTRESOURCE( IDR_MAINFRAME ) );
  248.  
  249.     // Set the icon for this dialog.
  250.     SendMessage( hDlg, WM_SETICON, ICON_BIG,   (LPARAM) hIcon );  // Set big icon
  251.     SendMessage( hDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIcon );  // Set small icon
  252.  
  253.     g_hDMusicMessageEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
  254.     g_pMusicManager = new CMusicManager();
  255.  
  256.     if( FAILED( hr = g_pMusicManager->Initialize( hDlg ) ) )
  257.         return DXTRACE_ERR( TEXT("Initialize"), hr );
  258.  
  259.     // Register segment notification
  260.     IDirectMusicPerformance* pPerf = g_pMusicManager->GetPerformance();
  261.     GUID guid = GUID_NOTIFICATION_SEGMENT;
  262.     pPerf->AddNotificationType( guid );
  263.     pPerf->SetNotificationHandle( g_hDMusicMessageEvent, 0 );  
  264.  
  265.     SendDlgItemMessage( hDlg, IDC_TEMPO_SLIDER, TBM_SETRANGE, FALSE, MAKELONG( 1, 7 ) );
  266.     SendDlgItemMessage( hDlg, IDC_TEMPO_SLIDER, TBM_SETTIC,   TRUE, 4 );
  267.     SendDlgItemMessage( hDlg, IDC_TEMPO_SLIDER, TBM_SETPOS,   TRUE, 4 );
  268.  
  269.     SendDlgItemMessage( hDlg, IDC_VOLUME_SLIDER, TBM_SETRANGE, FALSE, MAKELONG( 0, MUSIC_VOLUME_RANGE ) );
  270.     SendDlgItemMessage( hDlg, IDC_VOLUME_SLIDER, TBM_SETPOS,   TRUE, MUSIC_VOLUME_RANGE );
  271.  
  272.     // Load a default music segment 
  273.     TCHAR strFileName[MAX_PATH];
  274.     strcpy( strFileName, DXUtil_GetDXSDKMediaPath() );
  275.     strcat( strFileName, "sample.sgt" );
  276.     if( S_FALSE == LoadSegmentFile( hDlg, strFileName ) )
  277.     {
  278.         // Set the UI controls
  279.         SetDlgItemText( hDlg, IDC_FILENAME, TEXT("No file loaded.") );
  280.     }
  281.  
  282.     return S_OK;
  283. }
  284.  
  285.  
  286.  
  287.  
  288. //-----------------------------------------------------------------------------
  289. // Name: OnOpenSoundFile()
  290. // Desc: Called when the user requests to open a sound file
  291. //-----------------------------------------------------------------------------
  292. VOID OnOpenSoundFile( HWND hDlg ) 
  293. {
  294.     static TCHAR strFileName[MAX_PATH] = TEXT("");
  295.     static TCHAR strPath[MAX_PATH] = TEXT("");
  296.  
  297.     // Get the default media path (something like C:\MSSDK\SAMPLES\DMUSIC\MEDIA)
  298.     if( '\0' == strPath[0] )
  299.     {
  300.         const TCHAR* szDir = DXUtil_GetDXSDKMediaPath();
  301.         strcpy( strPath, szDir );
  302.     }
  303.  
  304.     // Setup the OPENFILENAME structure
  305.     OPENFILENAME ofn = { sizeof(OPENFILENAME), hDlg, NULL,
  306.                          TEXT("DirectMusic Content Files\0*.sgt;*.mid;*.rmi\0Wave Files\0*.wav\0All Files\0*.*\0\0"), NULL,
  307.                          0, 1, strFileName, MAX_PATH, NULL, 0, strPath,
  308.                          TEXT("Open Content File"),
  309.                          OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, 0, 0,
  310.                          TEXT(".sgt"), 0, NULL, NULL };
  311.  
  312.     if( g_pMusicSegment )
  313.         g_pMusicSegment->Stop( 0 );
  314.  
  315.     // Update the UI controls to show the sound as loading a file
  316.     EnableWindow(  GetDlgItem( hDlg, IDC_PLAY ), FALSE);
  317.     EnableWindow(  GetDlgItem( hDlg, IDC_STOP ), FALSE);
  318.     SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Loading file...") );
  319.  
  320.     // Display the OpenFileName dialog. Then, try to load the specified file
  321.     if( TRUE != GetOpenFileName( &ofn ) )
  322.     {
  323.         SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Load aborted.") );
  324.         return;
  325.     }
  326.  
  327.     if( S_FALSE == LoadSegmentFile( hDlg, strFileName ) )
  328.     {
  329.         // Not a critical failure, so just update the status
  330.         SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Could not create segment from file.") );
  331.     }
  332.  
  333.     // Remember the path for next time
  334.     strcpy( strPath, strFileName );
  335.     char* strLastSlash = strrchr( strPath, '\\' );
  336.     strLastSlash[0] = '\0';
  337. }
  338.  
  339.  
  340.  
  341.  
  342. //-----------------------------------------------------------------------------
  343. // Name: LoadSegmentFile()
  344. // Desc: 
  345. //-----------------------------------------------------------------------------
  346. HRESULT LoadSegmentFile( HWND hDlg, TCHAR* strFileName )
  347. {
  348.     HRESULT hr;
  349.  
  350.     SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
  351.  
  352.     // Free any previous segment, and make a new one
  353.     SAFE_DELETE( g_pMusicSegment );
  354.  
  355.     // Have the loader collect any garbage now that the old 
  356.     // segment has been released
  357.     g_pMusicManager->CollectGarbage();
  358.  
  359.     // Set the media path based on the file name (something like C:\MEDIA)
  360.     // to be used as the search directory for finding DirectMusic content
  361.     // related to this file.
  362.     TCHAR strMediaPath[MAX_PATH];
  363.     _tcscpy( strMediaPath, strFileName );
  364.     TCHAR* strLastSlash = _tcsrchr(strMediaPath, TEXT('\\'));
  365.     *strLastSlash = 0;
  366.     if( FAILED( hr = g_pMusicManager->SetSearchDirectory( strMediaPath ) ) )
  367.         return DXTRACE_ERR( TEXT("SetSearchDirectory"), hr );
  368.  
  369.     // For DirectMusic must know if the file is a standard MIDI file or not
  370.     // in order to load the correct instruments.
  371.     BOOL bMidiFile = FALSE;
  372.     if( strstr( strFileName, ".mid" ) != NULL ||
  373.         strstr( strFileName, ".rmi" ) != NULL ) 
  374.     {
  375.         bMidiFile = TRUE;
  376.     }
  377.  
  378.     BOOL bWavFile = FALSE;
  379.     if( strstr( strFileName, ".wav" ) != NULL )
  380.     {
  381.         bWavFile = TRUE;
  382.     }        
  383.  
  384.     // Load the file into a DirectMusic segment 
  385.     if( FAILED( g_pMusicManager->CreateSegmentFromFile( &g_pMusicSegment, strFileName, 
  386.                                                         TRUE, bMidiFile ) ) )
  387.     {
  388.         // Not a critical failure, so just update the status
  389.         return S_FALSE; 
  390.     }
  391.  
  392.     // Update the UI controls to show the segment is loaded
  393.     SetDlgItemText( hDlg, IDC_FILENAME, strFileName );
  394.     EnablePlayUI( hDlg, TRUE );
  395.     
  396.     // If we are loading a wav, then disable the tempo slider since 
  397.     // tempo adjustments will not take effect when playing wav files.
  398.     EnableWindow( GetDlgItem( hDlg, IDC_TEMPO_SLIDER ), !bWavFile );
  399.     EnableWindow( GetDlgItem( hDlg, IDC_TEMPO_GROUPBOX ), !bWavFile );
  400.     EnableWindow( GetDlgItem( hDlg, IDC_TEMPO_SLOWTXT ), !bWavFile );
  401.     EnableWindow( GetDlgItem( hDlg, IDC_TEMPO_FASTTXT ), !bWavFile );
  402.     EnableWindow( GetDlgItem( hDlg, IDC_TEMPO_NORMALTXT ), !bWavFile );
  403.  
  404.     return S_OK;
  405. }
  406.  
  407.  
  408.  
  409.  
  410. //-----------------------------------------------------------------------------
  411. // Name: ProcessDirectMusicMessages()
  412. // Desc: Handle DirectMusic notification messages
  413. //-----------------------------------------------------------------------------
  414. HRESULT ProcessDirectMusicMessages( HWND hDlg )
  415. {
  416.     HRESULT hr;
  417.     IDirectMusicPerformance8* pPerf = NULL;
  418.     DMUS_NOTIFICATION_PMSG* pPMsg;
  419.         
  420.     if( NULL == g_pMusicManager )
  421.         return S_OK;
  422.  
  423.     pPerf = g_pMusicManager->GetPerformance();
  424.  
  425.     // Get waiting notification message from the performance
  426.     while( S_OK == pPerf->GetNotificationPMsg( &pPMsg ) )
  427.     {
  428.         switch( pPMsg->dwNotificationOption )
  429.         {
  430.         case DMUS_NOTIFICATION_SEGEND:
  431.             if( pPMsg->punkUser )
  432.             {
  433.                 IDirectMusicSegmentState8* pSegmentState   = NULL;
  434.                 IDirectMusicSegment*       pNotifySegment   = NULL;
  435.                 IDirectMusicSegment8*      pNotifySegment8  = NULL;
  436.                 IDirectMusicSegment8*      pPrimarySegment8 = NULL;
  437.  
  438.                 // The pPMsg->punkUser contains a IDirectMusicSegmentState8, 
  439.                 // which we can query for the segment that the SegmentState refers to.
  440.                 if( FAILED( hr = pPMsg->punkUser->QueryInterface( IID_IDirectMusicSegmentState8,
  441.                                                                   (VOID**) &pSegmentState ) ) )
  442.                     return DXTRACE_ERR( TEXT("QueryInterface"), hr );
  443.  
  444.                 if( FAILED( hr = pSegmentState->GetSegment( &pNotifySegment ) ) )
  445.                 {
  446.                     // Sometimes the segend arrives after the segment is gone
  447.                     // This can happen when you load another segment as 
  448.                     // a motif or the segment is ending
  449.                     if( hr == DMUS_E_NOT_FOUND )
  450.                     {
  451.                         SAFE_RELEASE( pSegmentState );
  452.                         return S_OK;
  453.                     }
  454.  
  455.                     return DXTRACE_ERR( TEXT("GetSegment"), hr );
  456.                 }
  457.  
  458.                 if( FAILED( hr = pNotifySegment->QueryInterface( IID_IDirectMusicSegment8,
  459.                                                                  (VOID**) &pNotifySegment8 ) ) )
  460.                     return DXTRACE_ERR( TEXT("QueryInterface"), hr );
  461.  
  462.                 // Get the IDirectMusicSegment for the primary segment
  463.                 pPrimarySegment8 = g_pMusicSegment->GetSegment();
  464.  
  465.                 // Figure out which segment this is
  466.                 if( pNotifySegment8 == pPrimarySegment8 )
  467.                 {
  468.                     // Update the UI controls to show the sound as stopped
  469.                     EnablePlayUI( hDlg, TRUE );
  470.                 }
  471.  
  472.                 // Cleanup
  473.                 SAFE_RELEASE( pSegmentState );
  474.                 SAFE_RELEASE( pNotifySegment );
  475.                 SAFE_RELEASE( pNotifySegment8 );
  476.             }
  477.             break;
  478.         }
  479.  
  480.         pPerf->FreePMsg( (DMUS_PMSG*)pPMsg ); 
  481.     }
  482.  
  483.     return S_OK;
  484. }
  485.  
  486.  
  487.  
  488. //-----------------------------------------------------------------------------
  489. // Name: OnPlayAudio()
  490. // Desc: 
  491. //-----------------------------------------------------------------------------
  492. HRESULT OnPlayAudio( HWND hDlg )
  493. {
  494.     HRESULT hr;
  495.  
  496.     HWND hLoopButton = GetDlgItem( hDlg, IDC_LOOP_CHECK );
  497.     BOOL bLooped = ( SendMessage( hLoopButton, BM_GETSTATE, 0, 0 ) == BST_CHECKED );
  498.  
  499.     if( bLooped )
  500.     {
  501.         // Set the segment to repeat many times
  502.         if( FAILED( hr = g_pMusicSegment->SetRepeats( DMUS_SEG_REPEAT_INFINITE ) ) )
  503.             return DXTRACE_ERR( TEXT("SetRepeats"), hr );
  504.     }
  505.     else
  506.     {
  507.         // Set the segment to not repeat
  508.         if( FAILED( hr = g_pMusicSegment->SetRepeats( 0 ) ) )
  509.             return DXTRACE_ERR( TEXT("SetRepeats"), hr );
  510.     }
  511.  
  512.     // Play the segment and wait. The DMUS_SEGF_BEAT indicates to play on the 
  513.     // next beat if there is a segment currently playing. 
  514.     if( FAILED( hr = g_pMusicSegment->Play( DMUS_SEGF_BEAT ) ) )
  515.         return DXTRACE_ERR( TEXT("Play"), hr );
  516.  
  517.     EnablePlayUI( hDlg, FALSE );
  518.  
  519.     return S_OK;
  520. }
  521.  
  522.  
  523.  
  524.  
  525. //-----------------------------------------------------------------------------
  526. // Name: EnablePlayUI( hDlg,)
  527. // Desc: Enables or disables the Play UI controls 
  528. //-----------------------------------------------------------------------------
  529. VOID EnablePlayUI( HWND hDlg, BOOL bEnable )
  530. {
  531.     if( bEnable )
  532.     {
  533.         EnableWindow(   GetDlgItem( hDlg, IDC_LOOP_CHECK ), TRUE );
  534.         EnableWindow(   GetDlgItem( hDlg, IDC_STOP ),       FALSE );
  535.  
  536.         EnableWindow(   GetDlgItem( hDlg, IDC_PLAY ),       TRUE );
  537.         SetFocus(       GetDlgItem( hDlg, IDC_PLAY ) );
  538.     }
  539.     else
  540.     {
  541.         EnableWindow(  GetDlgItem( hDlg, IDC_LOOP_CHECK ), FALSE );
  542.         EnableWindow(  GetDlgItem( hDlg, IDC_STOP ),       TRUE );
  543.         SetFocus(      GetDlgItem( hDlg, IDC_STOP ) );
  544.         EnableWindow(  GetDlgItem( hDlg, IDC_PLAY ),       FALSE );
  545.     }
  546. }
  547.  
  548.  
  549.  
  550.